<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html" template="../template_back.xhtml">
  
  <ui:define name="content">
     <h:form>

    <p:dataTable id="dataTable" var="c" value="#{categoryController.categories}">
        <f:facet name="header"> Liste des categories </f:facet>
                
        <p:column sortBy="#{c.title}" headerText="Title">
            <h:inputText value="#{c.title}" size ="10" rendered="#{c.editable}"/>
            <h:outputText value="#{c.title}" rendered="#{not c.editable}"/>
        </p:column>
        
		<p:column headerText="Editer">
	    	<h:commandButton value="Edit" action="#{categoryController.editer}">
	    		<f:param name="categoryId" value="#{c.id}"/>
			</h:commandButton>
		</p:column>

        <p:column headerText="Delete">
			 <h:commandButton action="#{categoryController.delete}" value="Supprimer">
			 	<f:param name="categoryId" value="#{c.id}"/>
			 </h:commandButton>
        </p:column>    
    
    
    </p:dataTable>
    <p:commandButton value="Ajouter une categorie" action="#{categoryController.addNewCategory}" />
   
   	</h:form> 
                     
  </ui:define>
</ui:composition>
